package com.example.bms.mapper;
import com.example.bms.entity.PaperManage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;


/**
 * @apiNote 试卷的增加和查询
 * @author 任玥越
 * @email 3108289016@qq.com
 * @since 1.0.0
 */
@Mapper
public interface PaperMapper {


    /**
     * @apiNote 查询题库中所有试卷试题
     * @author 任玥越
     * @email 3108289016@qq.com
     * @return  List<PaperManage>
     * @since 1.0.0
     */
    @Select("select paperId, questionType,questionId from paper_manage")
    List<PaperManage> findAll();


    /**
     * @apiNote 查询对应试卷id的试题
     * @author 任玥越
     * @param paperId 试卷Id
     * - paperId 试卷id
     * - questionType 题目难度
     * - questionId 问题Id
     * @email 3108289016@qq.com
     * @return List<PaperManage>
     * @since 1.0.0
     */
    @Select("select paperId, questionType,questionId from paper_manage where paperId = #{paperId}")
    List<PaperManage> findById(Integer paperId);


    /**
     * @apiNote 增加试卷中的试题
     * @author 任玥越
     * @param paperManage 试题对象
     * - paperId 试卷id
     * - questionType 题目难度
     * - questionId 问题Id
     * @email 3108289016@qq.com
     * @return int类型，插入成功返回1，插入失败返回0
     * @since 1.0.0
     */
    @Insert("insert into paper_manage(paperId,questionType,questionId) values " +
            "(#{paperId},#{questionType},#{questionId})")
    int add(PaperManage paperManage);
}
